package cn.johnyu.service.impl;

import cn.johnyu.domain.Account;
import org.springframework.security.core.userdetails.ReactiveUserDetailsService;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Mono;

import java.util.List;

//@Service
public class InMemoryMockDetailsService2 implements ReactiveUserDetailsService {
    @Override
    public Mono<UserDetails> findByUsername(String username) {
        Account account=null;
        switch (username){
            case "admin":
                account = new Account().setUsername(username).setPassword("{noop}123").setRoles(List.of("ADMIN"));
                return Mono.just(account);
            case "john":
                account = new Account().setUsername(username).setPassword("{noop}123").setRoles(List.of("USER"));
                return Mono.just(account);
            case "tom":
                account = new Account().setUsername(username).setPassword("{noop}123").setRoles(List.of("ADMIN","USER"));
                return Mono.just(account);
            default:
                return Mono.empty();
        }
    }
}
